package com.atguigu.config;

import com.atguigu.pojo.Student;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/12/16 19:48
 * @注释
 */
@Configuration //将类设置为配置类
public class StudentConfig {

    @Bean(value = "studentone", initMethod = "init", destroyMethod = "destroy") //将所标记的返回值交给IOC容器管理
    @Scope("singleton") //设置所标记方法提供的Bean的作用域,singleton(默认)单例, prototype多例
    public Student student() {
        Student student = new Student();
        student.setId(1001);
        student.setName("张三");
        student.setAge(19);
        student.setGender("男");
        return student;
    }
}
